package com.ww.word.ui;

import java.io.File;

import android.content.Intent;
import android.os.Bundle;

import com.ww.core.activity.MyActivity;
import com.ww.word.ui.Constants;
import com.ww.core.util.CoreSharedPreferencesHelper;
import com.ww.core.util.DeviceUtil;
import com.ww.core.util.Logger;
import com.ww.core.util.StringUtils;

/**
 * @since 
 * @version 2013-12-13
 * @author wangwei
 */
public class DayDayUpActivity extends MyActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		CoreSharedPreferencesHelper h = new CoreSharedPreferencesHelper(DayDayUpActivity.this);
		boolean bool = false;
		String codeVersion = h.getValue("codeVersion");

		if (codeVersion == null) {
			h.setValue("codeVersion", DeviceUtil.getVersionCode(DayDayUpActivity.this) + "");
			bool = true;
			Logger.info("codeVersion=null");
		} else if (Integer.parseInt(codeVersion) < DeviceUtil.getVersionCode(DayDayUpActivity.this)) {
			File f = new File(Constants.DATABASE_PATH + Constants.DATABASE_NAME);
			if (f.exists()) {
				f.delete();
			}

			Logger.info("new version");
			bool = true;
		}

		if (!StringUtils.isNotEmpty(h.getValue("first"))) {
			h.setValue("first", "first");
			bool = true;
			Logger.info("first");
		}

		if (bool) {
			Intent intent = new Intent();
			intent.setClass(DayDayUpActivity.this, GuideActivity.class);
			startActivity(intent);
			finish();
		} else {
			Intent intent = new Intent();
			intent.setClass(DayDayUpActivity.this, SplashActivity.class);
			startActivity(intent);
			finish();
		}

	}

}